package br.ufpi.controllers.procedure;

import javax.persistence.EntityManager;
import javax.servlet.http.HttpServletRequest;

import br.com.caelum.vraptor.util.test.MockResult;
import br.com.caelum.vraptor.util.test.MockValidator;
import br.ufpi.commons.HttpRequestTest;
import br.ufpi.componets.UserSession;
import br.ufpi.componets.ValidateComponente;
import br.ufpi.controllers.LoginController;
import br.ufpi.repositories.UserRepository;
import br.ufpi.repositories.Implement.UserRepositoryImpl;

public class LoginTestProcedure {

	public static LoginController newInstanceLoginController(
			EntityManager entityManager) {

		HttpServletRequest request = new HttpRequestTest();

		MockResult result = new MockResult();
		MockValidator validator = new MockValidator();
		UserRepositoryImpl usuarioRepositoryImpl = new UserRepositoryImpl(
				entityManager);
		UserSession usuarioLogado = new UserSession(usuarioRepositoryImpl);
		ValidateComponente validateComponente = new ValidateComponente(
				validator);
		UserRepository usuarioRepository = new UserRepositoryImpl(
				entityManager);
		LoginController loginController = new LoginController(result, validator, usuarioLogado, validateComponente, usuarioRepository, request);
		return loginController;
	}

}
